package com.wgz.mp.generator.config;

import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @author wgz
 * @title
 * @Package PACKAGE_NAME
 * @data 2021/4/1 19:52
 */
@Configuration
@EnableWebMvc
@ComponentScan(value = "com.wgz.mp.generator",
        includeFilters = { @ComponentScan.Filter(type= FilterType.ANNOTATION,classes={Controller.class}),
        })
@Import(SpringConfig.class)
public class SpringMvcConfig  implements WebMvcConfigurer {


    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("js/**","/css/**").addResourceLocations("/js","/css/");
    }


    // 视图解析器
    @Bean
    public InternalResourceViewResolver viewResolver(){
        InternalResourceViewResolver i = new InternalResourceViewResolver();
        i.setPrefix("/");
        i.setSuffix(".jsp");
        return i;
    }
}
